namespace :db do
    desc "Loads the initial database fixtures."
    task :bootstrap => ['db:bootstrap:load']
    
    namespace :bootstrap do
        desc "Load initial database fixtures (in db/bootstrap/*.yml) into the current environment's database. "
        task :load => :environment do
            
            require 'active_record/fixtures'
            ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
            
            Fixtures.new(User.connection,"users",User,File.join(RAILS_ROOT, 'db', 'bootstrap',"users")).insert_fixtures
            ActiveRecord::Migration.execute "SELECT setval('users_id_seq', 2);"
            
            Fixtures.new(Link.connection,"links",Link,File.join(RAILS_ROOT, 'db', 'bootstrap',"links")).insert_fixtures
            ActiveRecord::Migration.execute "SELECT setval('links_id_seq', 15);"
            
            Fixtures.new(Relationship.connection,"relationships",Relationship,File.join(RAILS_ROOT, 'db', 'bootstrap',"relationships")).insert_fixtures
            ActiveRecord::Migration.execute "SELECT setval('relationships_id_seq', 2);"
            
            Fixtures.new(Didily.connection,"didilies",Didily,File.join(RAILS_ROOT, 'db', 'bootstrap',"didilies")).insert_fixtures
            ActiveRecord::Migration.execute "SELECT setval('didilies_id_seq', 14);"
            
            Fixtures.new(Path.connection,"paths",Path,File.join(RAILS_ROOT, 'db', 'bootstrap',"paths")).insert_fixtures
            ActiveRecord::Migration.execute "SELECT setval('paths_id_seq', 3);"
            
            Fixtures.new(DidiliesPaths.connection,"didilies_paths",DidiliesPaths,File.join(RAILS_ROOT, 'db', 'bootstrap',"didilies_paths")).insert_fixtures
            
        end
    end
end
